<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  components: {},
  data() {
    return {
      appWindow: window,
      form: {},
      // 表格查询数据
      mixinTable_tableSearchData: {
        // 父参数
        // dictType: "",
      },
      // 表格数据
      tableData: [],
      loading: true,
      detailInfo: null,

      editVisible: true,

      // 全部品牌
      brand: [],
      // 品牌id
      brand_id: "",
      // 商品id
      id: [],
    };
  },

  methods: {
    async submit() {
      let res = await this.$vFN.Http.post(
        {
          url: "mall-site-portal/product/batchProductBrand",
          data: {
            brandId: this.brand_id,
            productIdLst: this.id,
          },
        },
        window
      );

      if (res._ok) {
        this.editVisible = false;
        this.$vFN.Tools.messageSuccess("修改成功");
        this.onSuccess();
      }
    },

    // 初始化
    async init() {
      this.product_id.forEach((item) => {
        this.id.push(item.id);
      });
      console.log(this.id);

      if (this.index == 1) {
        let res = await this.$vFN.Http.post(
          {
            url: "mall-site-portal/product-brand/list",
          },
          window
        );
        this.brand = res.data.list;
      }

      this.loading = false;
      this.editVisible = true;
    },

    // 提交成功
    onSubmitSuccess() {
      this.onSuccess();
    },
    // 成功回调
    onSuccess() {},
    // 取消回调
    onCancel() {
      this.editVisible = false;
    },
    // 失败回调
    onError() {},
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>